package utils.socket_server;

import java.net.ServerSocket;
import java.net.Socket;


public class SocketManager {
	private Integer port = 15000;
	
	private void service(){
		//En caso de quuerer tener en el server socket una referencia a todos los hilos que inicia ("Thread")
		//Vector<Hilo> children = new Vector<Hilo>();		
		
		try {	
			boolean go=true;
			ServerSocket server = new ServerSocket(port);	
			System.out.println("ServerSocket - servicio - LISTENER");
			
			while (go) {
				try {
					Socket socket = server.accept();	
					socket.setSoTimeout(100000);
					SocketThread thread= new SocketThread(socket);
					thread.start();
					//children.add(socketServidor);
					//System.out.println("ServerSocketTCP - servicio - Child creado - total children: "+children.size());
				} catch (Exception e1) {					
					System.out.println("ServerSocketTCP - servicio - Exception "+ e1);
				}
			}
		} catch (Exception e) {
			System.out.println("ServerSocketTCP - servicio - Exception"+ e);
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		new SocketManager().service();
	}	
}



